# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sharpfuzz
pkgver=v2.2.0.r5.g15c453a
pkgrel=3
epoch=1
pkgdesc='AFL-based fuzz testing for .NET.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-fuzzer' 'blackarch-windows')
url='https://github.com/Metalnem/sharpfuzz'
license=('MIT')
depends=('afl++' 'dotnet-runtime')
makedepends=('git' 'dotnet-sdk')
source=("git+https://github.com/Metalnem/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" docs/*.md *.md

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  dotnet tool install --tool-path "$pkgdir/usr/bin" SharpFuzz.CommandLine
}

